import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import {NaiveUiResolver} from 'unplugin-vue-components/resolvers';
import * as path from "path";

// https://vitejs.dev/config/
export default ({mode}) => {
    return defineConfig({
        build: {
          target: "ESNEXT"
        },
        resolve: {
            alias: {
                "@": path.resolve(__dirname, "src"),
            },
        },
        server: {
            proxy: {
                "/api": {
                    target: "http://localhost:8080",
                    changeOrigin: true,
                    secure: false,
                    rewrite: (p) => p.replace(/^\/api/, ""),
                },
            },
        },
        plugins: [
            vue(),
            Components({
                resolvers: [NaiveUiResolver()]
            })
        ]
    });
}
